﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Drawing;


namespace HA.Data.DisplayOptions2
{
    [Serializable]
    public class DOMap : EventProperty ,ICloneable,IObjectDataHelper 
    {

        public DOMap()
        {
            this._specifiedHead = new DOEntity(Color.DarkMagenta, DisplayShape.Circle);
            //this._iBound = new DOEntity(Color.);

            this._specifiedConc = new DOEntity(Color.Black, DisplayShape.Diamond);
            this._specifiedFlow = new DOEntity(Color.Black, DisplayShape.Square);
            this._generalHead = new DOEntity(Color.Green, DisplayShape.TriangleUp);
            this._massLoad = new DOEntity(Color.Yellow, DisplayShape.TriangleUp);
            this._drain = new DOEntity(Color.Blue, DisplayShape.Diamond);
            this._seepage = new DOEntity(Color.Red, DisplayShape.Circle);
            this._river = new DOEntity(Color.Blue, DisplayShape.TriangleUp);
            this._barrier = new DOEntity(Color.SaddleBrown, DisplayShape.Circle);
            this._well = new DOEntity(Color.Gold, DisplayShape.Diamond);
            this.IBound = new DOEntity(Color.Black, DisplayShape.Circle);
        }



        DOEntity _specifiedHead;

        public DOEntity SpecifiedHead
        {
            get { return _specifiedHead; }
            set
            {
                if (_specifiedHead == value)
                {
                    return;
                }
                else
                {
                    _specifiedHead = value;
                    this.IsNeedUpdateData = true;
                }
            }
        }
        DOEntity _iBound;

        public DOEntity IBound
        {
            get { return _iBound; }
            set
            {
                if (_iBound == value)
                {
                    return;
                }
                else
                {
                    _iBound = value;
                    this.IsNeedUpdateData = true;
                }
            }
        }

        DOEntity _specifiedConc;

        public DOEntity SpecifiedConc
        {
            get { return _specifiedConc; }
            set
            {
                if (_specifiedConc == value)
                {
                    return;
                }
                else
                {
                    _specifiedConc = value;
                    this.IsNeedUpdateData = true;
                }
            }
        }

        DOEntity _specifiedFlow;

        public DOEntity SpecifiedFlow
        {
            get { return _specifiedFlow; }
            set
            {
                if (_specifiedFlow == value)
                {
                    return;
                }
                else
                {
                    _specifiedFlow = value;
                    this.IsNeedUpdateData = true;
                }
            }
        }

        DOEntity _generalHead;

        public DOEntity GeneralHead
        {
            get { return _generalHead; }
            set
            {
                if (_generalHead == value)
                {
                    return;
                }
                else
                {
                    _generalHead = value;
                    this.IsNeedUpdateData = true;
                }
            }
        }

        DOEntity _massLoad;

        public DOEntity MassLoad
        {
            get { return _massLoad; }
            set
            {
                if (_massLoad == value)
                {
                    return;
                }
                else
                {
                    _massLoad = value;
                    this.IsNeedUpdateData = true;
                }
            }
        }

        DOEntity _drain;

        public DOEntity Drain
        {
            get { return _drain; }
            set
            {
                if (_drain == value)
                {
                    return;
                }
                else
                {
                    _drain = value;
                    this.IsNeedUpdateData = true;
                }
            }
        }
        DOEntity _seepage;

        public DOEntity Seepage
        {
            get { return _seepage; }
            set
            {
                if (_seepage == value)
                {
                    return;
                }
                else
                {
                    _seepage = value;
                    this.IsNeedUpdateData = true;
                }
            }
        }


        DOEntity _river;

        public DOEntity River
        {
            get { return _river; }
            set
            {
                if (_river == value)
                {
                    return;
                }
                else
                {
                    _river = value;
                    this.IsNeedUpdateData = true;
                }
            }
        }

        DOEntity _barrier;

        public DOEntity Barrier
        {
            get { return _barrier; }
            set
            {
                if (_barrier == value)
                {
                    return;
                }
                else
                {
                    _barrier = value;
                    this.IsNeedUpdateData = true;
                }
            }
        }

        DOEntity _well;

        public DOEntity Well
        {
            get { return _well; }
            set
            {
                if (_well == value)
                {
                    return;
                }
                else
                {
                    _well = value;
                    this.IsNeedUpdateData = true;
                }
            }
        }





        public object Clone()
        {
            DOMap obj = new DOMap();
            obj.Barrier = (DOEntity)this.Barrier.Clone();
            obj.Drain = (DOEntity)this.Drain.Clone();
            obj.GeneralHead = (DOEntity)this.GeneralHead.Clone();
            obj.IBound = (DOEntity)this.IBound.Clone();
            obj.MassLoad = (DOEntity)this.MassLoad.Clone();
            obj.River = (DOEntity)this.River.Clone();
            obj.Seepage = (DOEntity)this.Seepage.Clone();
            obj.SpecifiedConc = (DOEntity)this.SpecifiedConc.Clone();
            obj.SpecifiedFlow = (DOEntity)this.SpecifiedFlow.Clone();
            obj.SpecifiedHead = (DOEntity)this.SpecifiedHead.Clone();
            obj.Well = (DOEntity)this.Well.Clone();
            return obj;
        }
      

        #region IObjectDataHelper 成员

        public void ResetDataAndTriggerEvent(object map)
        {
            if (map == null)
            {
                return;
            }

            DOMap nMap = (DOMap)map;


            if (nMap.IsDataChanged ()==false )
            {
                return;
            }


            try
            {
                List<string> props = new List<string>();

                if (this.Barrier != nMap.Barrier)
                {
                    this.Barrier = nMap.Barrier;
                    props.Add(DOMapType .Barrier.ToString ());
                }
                if (this.Drain != nMap.Drain)
                {
                    this.Drain = nMap.Drain;
                    props.Add(DOMapType.Drain.ToString());
                }
                if (this.GeneralHead != nMap.GeneralHead)
                {
                    this.GeneralHead = nMap.GeneralHead;
                    props.Add(DOMapType.GeneralHead.ToString ());
                }
                if (this.IBound != nMap.IBound)
                {
                    this.IBound = nMap.IBound;
                    props.Add(DOMapType.IBound.ToString ());
                }
                if (this.MassLoad != nMap.MassLoad)
                {
                    this.MassLoad = nMap.MassLoad;
                    props.Add(DOMapType.MassLoad.ToString ());
                }
                if (this.River != nMap.River)
                {
                    this.River = nMap.River;
                    props.Add(DOMapType.River.ToString ());
                }
                if (this.Seepage != nMap.Seepage)
                {
                    this.Seepage = nMap.Seepage;
                    props.Add(DOMapType.Seepage.ToString ());

                }
                if (this.SpecifiedConc != nMap.SpecifiedConc)
                {
                    this.SpecifiedConc = nMap.SpecifiedConc;
                    props.Add(DOMapType.SpecifiedConc.ToString ());
                }
                if (this.SpecifiedFlow != nMap.SpecifiedFlow)
                {
                    this.SpecifiedFlow = nMap.SpecifiedFlow;
                    props.Add(DOMapType.SpecifiedFlow.ToString ());
                }
                if (this.SpecifiedHead != nMap.SpecifiedHead)
                {
                    this.SpecifiedHead = nMap.SpecifiedHead;
                    props.Add(DOMapType.SpecifiedHead.ToString ());
                }
                if (this.Well != nMap.Well)
                {
                    this.Well = nMap.Well;
                    props.Add(DOMapType.Well.ToString());
                }


                if (props.Count > 0)
                {
                    this.AskDisplayOptionChanged(new DisplayOptionsChangedEventArgs(this, DisplayOptionsType.MapData, props));

                }

            }
            catch
            {


            }



        }

        public bool IsDataChanged(  )
        {
            //DOMap nMap = (DOMap)doMap;
            if (this==null )
            {
                return false;
            }
            if (this.IsNeedUpdateData == true)
            {
                return true;
            }
            else
            {

                return false;
            }

            //return true;
            //throw new NotImplementedException();
        }

        #endregion



        #region  暂时不使用


        //public void ResetDOMap(DOMap nMap)
        //{

        //    try
        //    {
        //        List<string> props = new List<string>();

        //        if (this.Barrier != nMap.Barrier)
        //        {
        //            this.Barrier = nMap.Barrier;
        //            props.Add("Barrier");
        //        }
        //        if (this.Drain != nMap.Drain)
        //        {
        //            this.Drain = nMap.Drain;
        //            props.Add("Drain");
        //        }
        //        if (this.GeneralHead != nMap.GeneralHead)
        //        {
        //            this.GeneralHead = nMap.GeneralHead;
        //            props.Add("GeneralHead");
        //        }
        //        if (this.IBound != nMap.IBound)
        //        {
        //            this.IBound = nMap.IBound;
        //            props.Add("IBound");
        //        }
        //        if (this.MassLoad != nMap.MassLoad)
        //        {
        //            this.MassLoad = nMap.MassLoad;
        //            props.Add("MassLoad");
        //        }
        //        if (this.River != nMap.River)
        //        {
        //            this.River = nMap.River;
        //            props.Add("River");
        //        }
        //        if (this.Seepage != nMap.Seepage)
        //        {
        //            this.Seepage = nMap.Seepage;
        //            props.Add("Seepage");

        //        }
        //        if (this.SpecifiedConc != nMap.SpecifiedConc)
        //        {
        //            this.SpecifiedConc = nMap.SpecifiedConc;
        //            props.Add("SpecifiedConc");
        //        }
        //        if (this.SpecifiedFlow != nMap.SpecifiedFlow)
        //        {
        //            this.SpecifiedFlow = nMap.SpecifiedFlow;
        //            props.Add("SpecifiedFlow");
        //        }
        //        if (this.SpecifiedHead != nMap.SpecifiedHead)
        //        {
        //            this.SpecifiedHead = nMap.SpecifiedHead;
        //            props.Add("SpecifiedHead");
        //        }
        //        if (this.Well != nMap.Well)
        //        {
        //            this.Well = nMap.Well;
        //            props.Add("Well");
        //        }
        //        if (props.Count > 0)
        //        {
        //            this.AskDisplayOptionChanged(new DisplayOptionsChangedEventArgs(this, DisplayOptionsType.MapData, props));
        //        }
        //    }
        //    catch
        //    {
        //    }
        //}



        #region 事件模型

        //[field: NonSerialized]
        //public event EventHandler<DisplayOptionsChangedEventArgs> DisplayOptionsChanged;

        //public void AskDisplayOptionChanged(DisplayOptionsChangedEventArgs e)
        //{
        //    if (DisplayOptionsChanged != null)
        //    {
        //        DisplayOptionsChanged(this, e);

        //    }
        //}


        #endregion


#endregion




    }
}
